package cn.slf.ph.servlet;

import cn.slf.ph.dao.CourierStationDao;
import cn.slf.ph.dao.impl.CourierStationDaoImpl;
import cn.slf.ph.entity.Community;
import cn.slf.ph.util.Result;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/getcommunitylist")
public class GetcommunitylistServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String action = req.getParameter("action");
        CourierStationDao courierStationDao = new CourierStationDaoImpl();
//                if ("getcommunitylist".equals(action)) {
        String pageNum = req.getParameter("pageNum");
        String pageSize = req.getParameter("pageSize");
        Map<String, String> map = new HashMap<>();
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);

//            //返回
//        List<Community> list = courierStationDao.getCommunityList(map);
//            int total = courierStationDao.communityCount(map);
//
        Map resultMap = new HashMap();
//        resultMap.put("list", list);
        Result success = Result.success(map);
//            resultMap.put("total", total);
        resp.getWriter().write(JSON.toJSONString(success));

//        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
